package com.example.shopping2.a_d_customview

import BaseActivity
import Tokencontract
import android.content.Intent
import android.widget.ImageView
import android.widget.TextView
import com.example.perplonews.a_a_mvp.presenter.presenters.TokenPresenter
import com.example.perplonews.a_b_utils.LjlUtils
import com.example.shopping2.MainActivity
import com.example.shopping2.R
import com.example.shopping2.a_a_mvp.model.models.TokenModel
import com.example.shopping2.timmer.TimmerHandler
import com.example.shopping2.timmer.TimmerThread

class SplashActivity : BaseActivity<TokenPresenter>(), Tokencontract.Token_MyView ,TimmerHandler.TimmerCallBack{
    private val splashImg: ImageView by lazy { findViewById<ImageView>(R.id.splash_img) }
    private val splashTime: TextView by lazy { findViewById<TextView>(R.id.splash_time) }

    override fun findlayout(): Int {
        return R.layout.activity_splash
    }

    override fun initView() {

    }

    override fun initData() {
        mypre = TokenPresenter(TokenModel(),this)
        mypre.requestToken()
        //开启计时器
        TimmerThread(TimmerHandler(this)).start()
    }

    override fun refresh() {

    }

    override fun callTimmer(time: Int) {
        splashTime.setText(""+time)
        if (time == 1){
            //跳转到主页面
            startActivity(Intent(this,MainActivity::class.java))
            finish()
        }
    }

}